package com.hubu.blog.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 用户-VIP关联表 表定义层。
 *
 * @author 331126135@qq.com
 * @since 2025-06-10
 */
public class UserVipTableDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户-VIP关联表
     */
    public static final UserVipTableDef USER_VIP = new UserVipTableDef();

    /**
     * 记录ID，雪花算法生成
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 套餐ID
     */
    public final QueryColumn PLAN_ID = new QueryColumn(this, "plan_id");

    /**
     * 状态
     */
    public final QueryColumn STATUS = new QueryColumn(this, "status");

    /**
     * 用户ID
     */
    public final QueryColumn USER_ID = new QueryColumn(this, "user_id");

    /**
     * 结束时间
     */
    public final QueryColumn END_TIME = new QueryColumn(this, "end_time");

    /**
     * 关联订单ID
     */
    public final QueryColumn ORDER_ID = new QueryColumn(this, "order_id");

    /**
     * 是否删除：0-未删除 1-已删除
     */
    public final QueryColumn IS_DELETED = new QueryColumn(this, "is_deleted");

    /**
     * 开始时间
     */
    public final QueryColumn START_TIME = new QueryColumn(this, "start_time");

    /**
     * 创建时间
     */
    public final QueryColumn CREATE_TIME = new QueryColumn(this, "create_time");

    /**
     * 删除时间
     */
    public final QueryColumn DELETE_TIME = new QueryColumn(this, "delete_time");

    /**
     * 更新时间
     */
    public final QueryColumn UPDATE_TIME = new QueryColumn(this, "update_time");

    /**
     * 是否自动续费(1是 0否)
     */
    public final QueryColumn IS_AUTO_RENEW = new QueryColumn(this, "is_auto_renew");

    /**
     * 删除原因
     */
    public final QueryColumn DELETE_REASON = new QueryColumn(this, "delete_reason");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, USER_ID, PLAN_ID, ORDER_ID, START_TIME, END_TIME, IS_AUTO_RENEW, STATUS, DELETE_REASON, CREATE_TIME, UPDATE_TIME, DELETE_TIME};

    public UserVipTableDef() {
        super("db_blog", "blog_user_vip");
    }

    private UserVipTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public UserVipTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new UserVipTableDef("db_blog", "blog_user_vip", alias));
    }

}
